/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hcbank.jpa.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author NHAHV
 */
@Entity
@Table(name = "Accounts")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AccountEntity.findAll", query = "SELECT a FROM AccountEntity a"),
    @NamedQuery(name = "AccountEntity.findById", query = "SELECT a FROM AccountEntity a WHERE a.id = :id"),
    @NamedQuery(name = "AccountEntity.findByNumber", query = "SELECT a FROM AccountEntity a WHERE a.number = :number"),
    @NamedQuery(name = "AccountEntity.findByPin", query = "SELECT a FROM AccountEntity a WHERE a.pin = :pin"),
    @NamedQuery(name = "AccountEntity.findByStatus", query = "SELECT a FROM AccountEntity a WHERE a.status = :status")})
public class AccountEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "Id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "Number")
    private String number;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 6)
    @Column(name = "PIN")
    private String pin;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Status")
    private boolean status;
    @JoinColumn(name = "CustomerId", referencedColumnName = "Id")
    @ManyToOne(optional = false)
    private CustomerEntity customerId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "accountId")
    private List<AccountHistoryEntity> accountHistoryEntityList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "toAccount")
    private List<TransactionEntity> transactionEntityList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fromAccount")
    private List<TransactionEntity> transactionEntityList1;

    public AccountEntity() {
    }

    public AccountEntity(Integer id) {
        this.id = id;
    }

    public AccountEntity(Integer id, String number, String pin, boolean status) {
        this.id = id;
        this.number = number;
        this.pin = pin;
        this.status = status;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getPin() {
        return pin;
    }

    public void setPin(String pin) {
        this.pin = pin;
    }

    public boolean getStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public CustomerEntity getCustomerId() {
        return customerId;
    }

    public void setCustomerId(CustomerEntity customerId) {
        this.customerId = customerId;
    }

    @XmlTransient
    public List<AccountHistoryEntity> getAccountHistoryEntityList() {
        return accountHistoryEntityList;
    }

    public void setAccountHistoryEntityList(List<AccountHistoryEntity> accountHistoryEntityList) {
        this.accountHistoryEntityList = accountHistoryEntityList;
    }

    @XmlTransient
    public List<TransactionEntity> getTransactionEntityList() {
        return transactionEntityList;
    }

    public void setTransactionEntityList(List<TransactionEntity> transactionEntityList) {
        this.transactionEntityList = transactionEntityList;
    }

    @XmlTransient
    public List<TransactionEntity> getTransactionEntityList1() {
        return transactionEntityList1;
    }

    public void setTransactionEntityList1(List<TransactionEntity> transactionEntityList1) {
        this.transactionEntityList1 = transactionEntityList1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AccountEntity)) {
            return false;
        }
        AccountEntity other = (AccountEntity) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.hcbank.jpa.controllers.AccountEntity[ id=" + id + " ]";
    }
    
}
